Recover from UDS socket loss by making BadSocketError retryable#330
Open
joshuay03 wants to merge 1 commit into
Open
Recover from UDS socket loss by making BadSocketError retryable#330joshuay03 wants to merge 1 commit into
BadSocketError retryable#330joshuay03 wants to merge 1 commit into
Conversation
1479786 to
4f9e1af
Compare
UDSConnection raises BadSocketError when sendmsg_nonblock hits ECONNREFUSED, ECONNRESET, or ENOENT, but Connection#write's retry list did not include it, so the socket was never closed and every subsequent send failed the same way for the lifetime of the process. Introduce Connection::RetryableError and make BadSocketError inherit from it. Connection#write now closes and reconnects before retrying.
4f9e1af to
8d2743d
Compare
BadSocketError retryable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We ran into this at @buildkite when the Datadog Agent restarted on one of our nodes: every
Datadog::Statsdinstance in our Ruby process stayed wedged on the dead socket fd and dropped custom metrics until the app restarted.UDSConnection#send_messagewrapsErrno::ECONNREFUSED,Errno::ECONNRESET, andErrno::ENOENTasBadSocketError, butConnection#write's retry list did not include it, so the socket was never closed.This PR introduces
Connection::RetryableError, makesBadSocketErrorinherit from it, and adds it to the retry list. The existing TODO inUDSConnection#send_messageand the# FIXME: BadSocketError is not correctly caught by Connection class to retrynotes in the UDS specs already recommended this shape; the previouslypending: trueand "does not correctly retry" specs flip to positive assertions.